﻿@using mojoPortal.Web.Helpers;
@using mojoPortal.Business;

@model PostListModel

<div class="blog-postlist">
	@foreach (var item in Model.Posts)
	{
		<article class="blog-postlist__item">

			<header>
				@if (!string.IsNullOrWhiteSpace(item.HeadlineImageUrl))
				{
					<figure class="blog-postlist__item-featured-image">
						<img src="@item.HeadlineImageUrl" alt="@item.Title" />
					</figure>
				}

				<h2 class="blog-postlist__title">
					<a class="blog-postlist__item-link" href="@item.ItemUrl">@item.Title</a>
				</h2>
				@if (@item.SubTitle != "")
				{
					<h3 class="blog-postlist__sub-title">@item.SubTitle</h3>
				}
			</header>

			<div class="blog-postlist__item-body">
				@Html.Raw(item.Body)
			</div>

			<footer>
				<div class="blog-postlist__metadata">
					@if (item.ShowAuthorName)
					{
						<span class="blog-postlist__author">
							@if (item.ShowAuthorAvatar && !item.ShowAuthorBio)
							{
								<span class="blog-postlist__author-avatar">
									@Html.Avatar(item.AuthorAvatar, item.AuthorEmail, item.AuthorUserId, new { Class = "author__avatar" }, new { Class = "author__avatar-link" }, true, true)
								</span>
							}
							<span class="blog-postlist__author-name">
								@if (!item.ShowAuthorAvatar || item.ShowAuthorBio)
								{
									<i class="fa fa-user-circle"></i>
								}
								@item.AuthorDisplayName
							</span>
						</span>
					}

					<span class="blog-postlist__date"><i class="fa fa-clock-o"></i> @item.PostDate.ToString("MMMM dd, yyyy")</span>

					@if (item.AllowCommentsForDays > -1)
					{
						<span class="blog-postlist__comments"><a class="blog-postlist__commentslink" href="@(item.ItemUrl)#comments"><i class="fa fa-comments"></i> @Resources.BlogResources.BlogFeedbackLabel (@item.CommentCount)</a></span>
					}
				</div>

				@if (item.ShowAuthorBio)
				{
					<div class="author__group author__group--blog-postlist media">
						@if (item.ShowAuthorAvatar)
						{
							@Html.Avatar(item.AuthorAvatar, item.AuthorEmail, item.AuthorUserId, new { Class = "author__avatar media-object" }, new { Class = "author__avatar-link media-left" }, true, true)
						}

						@if (item.ShowAuthorBio && !string.IsNullOrWhiteSpace(item.AuthorBio))
						{
							<p class="author__bio media-body">@item.AuthorBio</p>
						}
					</div>
				}

			</footer>
		</article>
	}
	<p><a href="@Model.ModulePageUrl">View all posts</a> &#187;</p>
</div>